home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / triv_lib / trivmesh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-11  |  3.2 KB  |  87 lines

  1. /******************************************************************************
  2. * CagdMesh.c - Extract surface control mesh/curve control polygon as polyline *
  3. *******************************************************************************
  4. * Written by Gershon Elber, Aug. 90.                          *
  5. ******************************************************************************/
  6.  
  7. #include "triv_loc.h"
  8.  
  9. /*****************************************************************************
  10. * DESCRIPTION:                                                               M
  11. * Extracts the control mesh of a surface as a list of polylines.         M
  12. *                                                                            *
  13. * PARAMETERS:                                                                M
  14. *   Srf:        To extract a control mesh from.                             M
  15. *                                                                            *
  16. * RETURN VALUE:                                                              M
  17. *   CagdPolylineStruct *:  The control mesh of Srf.                          M
  18. *                                                                            *
  19. * KEYWORDS:                                                                  M
  20. *   TrivTV2CtrlMesh, control mesh                                           M
  21. *****************************************************************************/
  22. CagdPolylineStruct *TrivTV2CtrlMesh(TrivTVStruct *Trivar)
  23. {
  24.     int i, j, k,
  25.     ULength = Trivar -> ULength + (Trivar -> UPeriodic != FALSE),
  26.     VLength = Trivar -> VLength + (Trivar -> VPeriodic != FALSE),
  27.     WLength = Trivar -> WLength + (Trivar -> WPeriodic != FALSE);
  28.     CagdRType
  29.     **TrivarP = Trivar -> Points;
  30.     CagdPolylnStruct *NewPolyline;
  31.     CagdPolylineStruct *P,
  32.     *PList = NULL;
  33.  
  34.     for (k = 0; k < WLength; k++) {       /* Generate the rows of the mesh. */
  35.     for (j = 0; j < VLength; j++) {
  36.         P = CagdPolylineNew(ULength);
  37.         NewPolyline = P -> Polyline;
  38.  
  39.         for (i = 0; i < ULength; i++) {
  40.         CagdCoerceToE3(NewPolyline -> Pt, TrivarP,
  41.                    TRIV_MESH_UVW(Trivar, i % Trivar -> ULength,
  42.                                  j % Trivar -> VLength,
  43.                                  k % Trivar -> WLength),
  44.                    Trivar -> PType);
  45.         NewPolyline++;
  46.         }
  47.         LIST_PUSH(P, PList);
  48.     }
  49.     }
  50.  
  51.     for (k = 0; k < WLength; k++) {       /* Generate the cols of the mesh. */
  52.     for (i = 0; i < ULength; i++) {
  53.         P = CagdPolylineNew(VLength);
  54.         NewPolyline = P -> Polyline;
  55.  
  56.         for (j = 0; j < VLength; j++) {
  57.         CagdCoerceToE3(NewPolyline -> Pt, TrivarP,
  58.                    TRIV_MESH_UVW(Trivar, i % Trivar -> ULength,
  59.                                  j % Trivar -> VLength,
  60.                                  k % Trivar -> WLength),
  61.                    Trivar -> PType);
  62.         NewPolyline++;
  63.         }
  64.         LIST_PUSH(P, PList);
  65.     }
  66.     }
  67.  
  68.     for (i = 0; i < ULength; i++) {     /* Generate the depths of the mesh. */
  69.     for (j = 0; j < VLength; j++) {
  70.         P = CagdPolylineNew(VLength);
  71.         NewPolyline = P -> Polyline;
  72.  
  73.         for (k = 0; k < WLength; k++) {
  74.         CagdCoerceToE3(NewPolyline -> Pt, TrivarP,
  75.                    TRIV_MESH_UVW(Trivar, i % Trivar -> ULength,
  76.                                  j % Trivar -> VLength,
  77.                                  k % Trivar -> WLength),
  78.                    Trivar -> PType);
  79.         NewPolyline++;
  80.         }
  81.         LIST_PUSH(P, PList);
  82.     }
  83.     }
  84.  
  85.     return PList;
  86. }
  87.